package com.koron.bean.enums;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;

/**
 * @author twcao
 * @title: TimePeriod
 * @projectName GDH_EAM_V2
 * @description: 时间周期
 * @date 2021/12/2111:51
 */
public enum TimePeriod {

    HOUR("HOUR", "时"),
    DAY("DAY", "天"),
    WEEK("WEEK", "周"),
    MONTH("MONTH", "月");

    private String key;

    private String value;

    TimePeriod(String key, String value) {
        this.key = key;
        this.key = value;
    }

    public static TimePeriod parse(String text) {
        Assert.hasText(text, "枚举类型不能为空");
        if(StringUtils.equals(text, "HOUR")) {
            return TimePeriod.HOUR;
        }
        if(StringUtils.equals(text, "DAY")) {
            return TimePeriod.DAY;
        }
        if(StringUtils.equals(text, "WEEK")) {
            return TimePeriod.WEEK;
        }
        if(StringUtils.equals(text, "MONTH")) {
            return TimePeriod.MONTH;
        }
        Assert.hasText(text, "枚举类型不存在");
        return null;
    }

}
